import an39 from '@mmstudio/an000039';
import { NextApiRequest } from 'next';
import getkey from './key';

/**
 * 从Cookie中获取数据
 */
export default function getuser(req: NextApiRequest) {
	const key = getkey();
	// 打包编译时req.cookies为空
	if (!req.cookies) {
		return null;
	}
	const token = req.cookies[key];
	return an39<Omit<ITbfduser, 'psw'> & { role: string; }>(token);
}
